Skip to main content

Periphery

The periphery contract is the main koindx contract, its function is to be the intermediary between the different token pools and the end user. Among its functions is to calculate the entry and exit inputs of tokens to add and remove liquidity, token swap and pool verification.

Contract Addresses

NetworkAddress
Koinos Mainnet17e1q6Fh5RgnuA8K7v4KvXXH4k9qHgsT5s
Koinos Harbinger18MV8beHrgV78JpHxTXrvPfSmP2kWy7DVk

Read-Only Functions

get_config

Method used to get the current Periphery contract settings, this method has no parameters.

get_pair

Method used to obtain the contract address where a pool of a respective pair is hosted.

ParamsDescription
token_atoken a used in the pool
token_btoken b used in the pool

get_quote

Method used to amount the equivalent amount of a token using the amount of an asset and reserves.

ParamsDescription
amountBase asset with which you want to calculate
reserve_aReserve of token a
reserve_bReserve of token B

get_amount_out

Method used to calculate the amount of token that the user will receive if he enters a specified amount of token.

ParamsDescription
amountBase asset with which you want to calculate
reserve_aReserve of token a
reserve_bReserve of token B

get_amount_in

Method used to calculate the amount of token that the user would have to send if he enters a specific amount of token.

ParamsDescription
amountBase asset with which you want to calculate
reserve_aReserve of token a
reserve_bReserve of token B

State-Changing Functions

authorize_update

Method used to allow Periphery contract updates using a hash to control updates.

ParamsDescription
hashIt is a sha256 created with the wasm file of the contract used to allow updates of

set_config

Method used to update the Periphery contract settings.

ParamsDescription
valueThese are the new configurations that the periphery contract will have

create_pair

Method used to create a new pool in the koindx protocol.

ParamsDescription
token_atoken a used for the new pool
token_atoken b used for the new pool

add_liquidity

Method used to add liquidity to a pair.

ParamsDescription
token_atoken a of the pool to which you want to add liquidity
token_btoken b of the pool to which you want to add liquidity
amount_a_desiredIt is the liquidity of token a desired to add to the pair
amount_b_desiredIt is the liquidity of token b desired to add to the pair
amount_a_minIt is the minimum liquidity of token a entered into the pair
amount_b_minIt is the minimum liquidity of token b entered into the pair

remove_liquidity

Method used to remove liquidity from a pair.

ParamsDescription
token_atoken a of the pool to which you want to add liquidity
token_btoken b of the pool to which you want to add liquidity
liquidityamount of liquidity tokens that you want to burn to remove liquidity from the pair
amount_a_minMinimum token that the user wants to receive after removing tokens from the pair
amount_b_minMinimum token that the user wants to receive after removing tokens from the pair

swap_tokens_in

Method used to swap tokens using the exact input amount of tokens

ParamsDescription
amount_inExact amount of input the user wants to exchange for x output token
amount_out_minMinimum number of tokens that the user wants to receive for his number of input tokens
pathRoute that is carried out to do the token swap can be 1 single pair or multiple pairs
receiverAddress where the output tokens will be received

swap_tokens_out

Method used to swap tokens using the exact amount of token output

ParamsDescription
amount_outAmount of output specifies that the user wants to receive
amount_in_maxMaximum amount the user is willing to pay for x number of output tokens
pathamount of liquidity tokens that you want to burn to remove liquidity from the pair
receiverAddress where the output tokens will be received